﻿using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Mvc;

namespace LmgCMS.Middleware {
    /// <summary>
    /// 我们需要验证我们的模型对象是否符合我们的预期
    /// </summary>
    public class ModelValidationAttribute: ActionFilterAttribute {
        public override void OnActionExecuting(ActionExecutingContext context) {
            if(!context.ModelState.IsValid) {
                context.Result = new BadRequestObjectResult(context.ModelState);
            }
        }
    }
}
